const { addrFormatterError } = require("../constants/err.type")

const validator = (rules) => {
  return async (ctx,next) =>{
    try {
      await ctx.verifyParams(rules)
    } catch (error) {
      console.error(error)
      addrFormatterError.result = error
      return ctx.app.emit('error',addrFormatterError,ctx)
    }

    await next()
  }
}

module.exports = {
  validator
}